package com.ruoyi.project.wenyanwen.generate.convert;


import com.ruoyi.project.dict.cizunew.domain.Cizu;
import com.ruoyi.project.wenyanwen.generate.domain.sqlite.CizuSqlite;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @author jackyshi
 */
@Component
public class CizuTinyConvert extends BaseCizuConvert {

    protected static Log logger = LogFactory.getLog(CizuTinyConvert.class);

    @Override
    public List<CizuSqlite> convert(List<?> list) {

        List<CizuSqlite> l = new ArrayList<>();

        for (Object obj : list) {

            Cizu cizu = (Cizu) obj;
            CizuSqlite model = new CizuSqlite();
            model.set_id(cizu.getId().intValue());
            model.setCi(cizu.getCi());
            model.setType(cizu.getType().intValue());
            model.setCipin(cizu.getCipin().intValue());
            model.setPy(cizu.getPy());
            model.setPinyin(cizu.getPinyin());
            model.setTongyici(cizu.getTongyici());
            model.setFanyici(cizu.getFanyici());
            if (cizu.getFlag() == 1) {
                model.setZhujie(encrypt(buildDesc(cizu)));
            }
            l.add(model);
        }

        return l;
    }

}
